package com.ufo.od;

import java.util.Arrays;
import java.util.Scanner;

/**
* A公司准备对他旗下N个产品评选最差奖，评选方式是首先对每个产品进行评分，然后根据评分区间计算相邻
 * 几个产品中最差的。评选标准是一次找到从当前产品开始前M个产品中最差的产品，请给出最差产品的评分序列
* */
public class WorstProduct {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int m = scanner.nextInt();
        scanner.nextLine();
        String[] split = scanner.nextLine().split(",");
        int[] scores = Arrays.stream(split).mapToInt(Integer::parseInt).toArray();
        System.out.println(Arrays.toString(scores));
        int[] worstScore = getWorstScore(scores, m);

        System.out.println(Arrays.toString(worstScore));
    }

    public static int[] getWorstScore(int[] scores,int m){
        int len=scores.length;
        if(len==1)return scores;
        if(m>len)m=len;
        int rLen=len-m+1;
        int[] result=new int[rLen];
        int rIdx=0;
        for(int i=m-1; i<len; i++){
            int min=scores[i];
            for(int j=i-m+1; j<i; j++){
                System.out.print(i+"+"+j+": ");
                min = Math.min(scores[j],min);
                System.out.println(min);
            }
            result[rIdx++]=min;
        }
        return result;
    }
}
